package com.finace.management.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.entity.PageResult;
import com.finace.management.service.TbSchoolService;
import com.finace.mapper.TbSchoolMapper;
import com.finace.pojo.TbSchool;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.List;

@Service
public class TbSchoolServiceImpl implements TbSchoolService {

    @Autowired
    private TbSchoolMapper tbSchoolMapper;

    @Override
    public List<TbSchool> tbschoolfindlist() {
        return tbSchoolMapper.selectByExample(null);
    }

    @Override
    public PageResult findlist(int pageNum, int pagesize) {
        PageHelper.startPage(pageNum, pagesize);

        Page<TbSchool> plist= (Page<TbSchool>) tbSchoolMapper.selectByExample(null);

        return new PageResult(plist.getTotal(),plist.getResult());
    }

    @Override
    public TbSchool findbyid(int id) {
        return tbSchoolMapper.selectByPrimaryKey(id);
    }

    @Override
    public int xiugaistatus(TbSchool tbSchool) {

        return tbSchoolMapper.updateByPrimaryKeySelective(tbSchool);

    }

    @Override
    public void add(TbSchool tbSchool) {

        tbSchool.setStatus(0);

        tbSchool.setCreateTime(new Date());

        tbSchoolMapper.insert(tbSchool);
    }

    @Override
    public void update(TbSchool tbSchool) {

        tbSchoolMapper.updateByPrimaryKey(tbSchool);

    }
}
